using System;
using System.Collections.Generic;

namespace DataLite.Values
{
    public class SqliteMasterVO
    {
        public SqliteMasterVO()
        {
            colummnInfo = new List<ColumnInfoVO>();
        }

        int rowId;
        public int RowId
        {
            get { return rowId; }
            set { rowId = value; }
        }

        string type;
        public string Type
        {
            get { return type; }
            set { type = value; }
        }

        string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        string entityName;
        public string EntityName
        {
            get { return entityName; }
            set { entityName = value; }
        }

        string tblName;
        public string TblName
        {
            get { return tblName; }
            set { tblName = value; }
        }

        int rootPage;
        public int RootPage
        {
            get { return rootPage; }
            set { rootPage = value; }
        }

        string sql;
        public string Sql
        {
            get { return sql; }
            set { sql = value; }
        }

        public string FormatSql { get {            
            string r = sql.Replace("\"", "'");
            r = r.Replace("\n", " ");
            r = r.Replace("\t", string.Empty);
            return r;
        } }        

        List<ColumnInfoVO> colummnInfo;
        public List<ColumnInfoVO> ColumnInfo
        {
            get { return colummnInfo; }
            set { colummnInfo = value; }
        }

        int pkCount;
        public int PkCount
        {
            get { return pkCount; }
            set { pkCount = value; }
        }

        bool anyIsNull;
        public bool AnyIsNull
        {
            get { return anyIsNull; }
            set { anyIsNull = value; }
        }
        
        public bool AutoIncrement
        {
            get 
            {
                int oPkColCount = 0;
                foreach (ColumnInfoVO col in colummnInfo)
                {
                    if (col.Pk == 1 && col.Type == "INTEGER") { oPkColCount++; }
                }
                if (oPkColCount == 1) return true;
                return false;
            }            
        }
    }
}
